'use strict';
var screenfull = require('screenfull');
//////////////////////////////////////////////////////////////////////////////
// 全屏功能
// =====================
// liuyp 2019年2月21日18:44:25
//////////////////////////////////////////////////////////////////////////////
function fullScreen($document, $window) {
    return {
        restrict: 'AC',
        template:'<i class="fa fa-expand fa-fw screenfullItem1"></i><i class="fa fa-compress fa-fw screenfullItem2"></i>',
        link: function(scope, el, attr) {
            el.addClass('screenfull');
            // disable on ie11
            if (screenfull.enabled && !navigator.userAgent.match(/Trident.*rv:11\./)) {
            }else{ el.remove();}
            el.on('click', function(){
                var target;
                attr.target && ( target = $(attr.target)[0] );
                screenfull.toggle(target);
            });
            $document.on(screenfull.raw.fullscreenchange, function () {
                if(screenfull.isFullscreen){ el.addClass('screenfullActive'); }
                else{ el.removeClass('screenfullActive'); }
            });
        }
    };
}
exports = module.exports = fullScreen;